package com.teach.customer.controller;

import com.common.bean.PageVo;
import com.common.bean.QueryCondition;
import com.common.bean.Response;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.validation.annotation.Validated;
import springfox.documentation.annotations.ApiIgnore;

import com.teach.customer.service.impl.ImsHcCmsCustomerServiceImpl;
import com.teach.customer.model.po.ImsHcCmsCustomerPO;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 * @version 1.0
 * @author hzz
 * @since 2021-04-22
 */
@RestController
@RequestMapping("/v1//imsHcCmsCustomer")
@Api(value = "API - ", tags = "")
@Validated
public class ImsHcCmsCustomerController {
    @Autowired
    private ImsHcCmsCustomerServiceImpl ImsHcCmsCustomerservice;

    @GetMapping("/index")
    @ApiIgnore
    public String fun(HttpServletRequest request,HttpServletResponse response){
        return "ok";
    }
    /**
     * 列表
     */
    @ApiOperation("分页查询(排序)")
    @GetMapping("/list")
    public Response<PageVo> getList(QueryCondition queryCondition){
        QueryWrapper<ImsHcCmsCustomerPO> queryWrapper = new QueryWrapper<>();
        PageVo page = ImsHcCmsCustomerservice.queryPage(queryCondition,queryWrapper);
        return Response.ok(page);
    }
    /**
     * 信息
     */
    @ApiOperation("详情查询")
    @GetMapping("/info")
    public Response<ImsHcCmsCustomerPO> info(@RequestParam("id") Integer id){
		ImsHcCmsCustomerPO info = ImsHcCmsCustomerservice.getById(id);

        return Response.ok(info);
    }
    /**
     * 保存
     */
    @ApiOperation("保存")
    @PostMapping("/save")
    public Response<Object> save(@RequestBody(required = true) ImsHcCmsCustomerPO entity){
        ImsHcCmsCustomerservice.saveOrUpdate(entity);
        return Response.ok(null);
    }
    /**
     * 删除
     */
    @ApiOperation("删除")
    @PostMapping("/delete")
    public Response<Object> delete(@RequestParam("id")Integer id){
        return Response.ok(ImsHcCmsCustomerservice.removeById(id));
    }
}

